package com.mine.modules.vm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mine.common.domain.vo.Result;
import com.mine.common.utils.ToTreeUtil;
import com.mine.modules.vm.entity.VmLayer;
import com.mine.modules.vm.entity.VmPermissionLayer;
import com.mine.modules.vm.entity.VmPersonnelDepart;
import com.mine.modules.vm.mapper.VmPersonnelDepartMapper;
import com.mine.modules.vm.service.IVmPersonnelDepartService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xujf
 * @since 2024-12-24
 */
@Service
public class VmPersonnelDepartServiceImpl extends ServiceImpl<VmPersonnelDepartMapper, VmPersonnelDepart> implements IVmPersonnelDepartService {

    @Override
    public Result<?> treeListDepart() {
        try {
            List<VmPersonnelDepart> list = this.list();
            List<VmPersonnelDepart> treeList = new ArrayList<>();
            ToTreeUtil.getTreeList(treeList, list, null);
            return Result.OK("查询成功！", treeList);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Result.error(e.getMessage());
        }
    }
}
